package UDPpractice;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

public class setMassage {
    public static void main(String[] args) throws IOException {
        // 创建快递公司
        DatagramSocket ds = new DatagramSocket();

        while (true) {
            // 压缩货物
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入你想要发送的货物");
            String s = sc.nextLine();
            if(s.equals("886")){
                break;
            }
            byte[] bytes = s.getBytes();

            InetAddress address = InetAddress.getByName("haiwen");

            DatagramPacket dp = new DatagramPacket(bytes,bytes.length,address,10086);

            // 发送
            ds.send(dp);
        }

        // 释放资源
        ds.close();

    }
}
